package elka.sag.logisticsystem.service.impl;

import java.util.ArrayList;
import java.util.List;

import elka.sag.logisticsystem.bean.Article;
import elka.sag.logisticsystem.bean.BusinesProcesStatus;
import elka.sag.logisticsystem.bean.Document;
import elka.sag.logisticsystem.bean.Order;
import elka.sag.logisticsystem.bean.Order.OrderStatus;
import elka.sag.logisticsystem.service.RepositoryService;

/**
 * Implementacja do testow
 * @author Wojtek
 *
 */
public class StubRepositoryService implements RepositoryService {

	public List<Order> getOrderForProcessing() {
		List<Order> orders = new ArrayList<Order>(5);
		
		for(int i=0; i<1 ; ++i) {
			Order tmpOrder = new Order();
			tmpOrder.setId(Long.valueOf(i));
			tmpOrder.setStatus(Order.OrderStatus.DOC_GENERATOR);
			
			List<Article> orderArticles = new ArrayList<Article>();
			for(int j=0; j<3 ; ++j) {
				Article article = new Article();
				article.setId(j);
				article.setName("Towar_" + j);
                article.setReserved(false);
				orderArticles.add(article);
			}
			setOrderArticles(orderArticles, tmpOrder.getId());
			orders.add(tmpOrder);
			
			
		}
		return orders;
	}

	public List<BusinesProcesStatus> getBusinesProcesStatuses() {
		List<BusinesProcesStatus> statuses = new ArrayList<BusinesProcesStatus>();
		

		BusinesProcesStatus newStatus = new BusinesProcesStatus();
		newStatus.setStatus(Order.OrderStatus.NOTIFICATION);
		newStatus.setActorName("elka.sag.logisticsystem.actor.NotificationActor");
		
		BusinesProcesStatus newStatus2 = new BusinesProcesStatus();
		newStatus2.setStatus(Order.OrderStatus.INVENTORY);
		newStatus2.setActorName("elka.sag.logisticsystem.actor.InventoryActor");

		BusinesProcesStatus newStatus3 = new BusinesProcesStatus();
		newStatus3.setStatus(Order.OrderStatus.DOC_GENERATOR);
		newStatus3.setActorName("elka.sag.logisticsystem.actor.DocGeneratorActor");
		
		statuses.add(newStatus);
		statuses.add(newStatus2);
		statuses.add(newStatus3);
		
		return statuses;
	}

    @Override
    public void updateOrderStatusAndProcess(Order order) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void removeOderDocuments(long orderId) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setDocuments(List<Document> documents, long orderId) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<Article> getOrderArticles(long orderId) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setOrderArticles(List<Article> orderArticles, long orderId) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isOrderComplete(long orderId) {
        //To change body of implemented methods use File | Settings | File Templates.
        return false;
    }

    public void updateOrder(Order order) {
		// TODO Auto-generated method stub
		
	}

	public Order getOrderById(Long orderId) {
		Order order = new Order();
		order.setId(orderId);
		order.setStatus(Order.OrderStatus.NEW);
		List<Article> orderArticles = new ArrayList<Article>();
		for(int j=0; j<3 ; ++j) {
			Article article = new Article();
			article.setId(j);
			article.setName("Towar_" + j);
            article.setReserved(false);
			orderArticles.add(article);
		}
		setOrderArticles(orderArticles, orderId);
		
		return order;
	}

	public List<String> getWarehouseNames() {
		List<String> warehouseNames = new ArrayList<String>();
		warehouseNames.add("mag1");
		warehouseNames.add("mag2");
		warehouseNames.add("mag3");
		return warehouseNames;
	}

	@Override
	public OrderStatus getNextStatus(OrderStatus status) {
		return Order.OrderStatus.COMPLETE;
	}

	@Override
	public String getParam(String brokenNotification) {
		return "Y";
	}

    @Override
    public boolean reserveArticle(String warehouseName, int articleId) {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void produceArticle(String warehouseName, int articleId) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int getNumberOfArticles(String warehouseName, int articleId) {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<Document> getDocuments(long orderId) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

}
